
package com.kaciula.letsdoit.ui;

import com.kaciula.utils.StorageHelper;

import android.app.Application;

public class MyApplication extends Application {

    private PreferenceHelper mPrefHelper;

    @Override
    public void onCreate() {
        super.onCreate();
        initStuff();
    }

    @Override
    public void onTerminate() {
        removeStuff();
        super.onTerminate();
    }

    private void initStuff() {
        mPrefHelper = new PreferenceHelper(this);
        StorageHelper.startWatchingExternalStorage(this);
        createPicsDir();
        mPrefHelper.saveGeneralInfo("nume", "prenume");
    }

    private void removeStuff() {
        StorageHelper.stopWatchingExternalStorage(this);
    }

    private void createPicsDir() {
        String path = getPackageName() + "/" + Constants.PICS_DIR;

        if (StorageHelper.createDir(path)) {
            mPrefHelper.savePicsPath(path);
        }
    }

    /**
     * @return the mPrefHelper
     */
    public PreferenceHelper getPrefHelper() {
        return mPrefHelper;
    }
}
